<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
	Long sysMills = System.currentTimeMillis();
	request.setAttribute("sysMills", sysMills);
%>
<script>
	$(document).ready(function() {
		$('#simple-button').popover('#simple-popover', {});
		$('#top-button').popover('#top-popover', {
			preventLeft : true,
			preventRight : true,
			preventBottom : true
		});
	});
</script>
<style type="text/css">
.title1 {
	background-color: #EAEFF4;
	color: #006699;
	font-size: 14px;
	font-weight: bold;
	overflow: auto;
	padding: 2px 6px;
}
</style>
<table class="display" id="example">
	<thead>
		<tr>
			<th>开始日期</th>
			<th>结束日期</th>
			<th>培训对象</th>
			<th>培训课程</th>
			<th>状态</th>
			<th>讲师</th>
			<th>评价</th>
		</tr>
	</thead>
	<tbody>
		<s:if test="#request.plans==null || #request.plans.size<=0">
			<tr class="gradeA">
				<td colspan="9">暂无数据</td>
			</tr>
		</s:if>
		<s:else>
			<s:iterator var="plan" status="sta" value="#request.plans">
				<s:if test="#sta.even">
					<tr class="gradeA">
				</s:if>
				<s:else>
					<tr class="gradeC">
				</s:else>
				<td><fmt:formatDate value="${plan.planStartDate}"
						pattern="yyyy-MM-dd HH:mm" /></td>
				<td><fmt:formatDate value="${plan.planEndDate}"
						pattern="yyyy-MM-dd HH:mm" /></td>
				<td><span name="td_dutytarget" title="${plan.id}"></span></td>
				<td>${plan.title}</td>
				<td>
					<s:if test="#plan.cancel == 1">取消</s:if>
					<s:elseif test="#plan.amendReason != null">已延期</s:elseif>
					<s:elseif test="#plan.planStartDate.time > #request.sysMills">未开始</s:elseif>
					<s:elseif test="#plan.planStartDate.time <= #request.sysMills && #plan.planEndDate.time >= #request.sysMills">进行中</s:elseif>
					<s:else>已结束</s:else>
				</td>
				<td>${plan.outingLecturer}</td>
				<td>
					<s:if test="#plan.planEndDate.time <= #request.sysMills">
					<a class="button" href="javascript:void(0)"
					onclick="showAssessContent(${plan.id})"><span
						style="background: url(${ctx}/images/img/report_magnify.png)"
						class="icon icon-ok">&nbsp;</span>查看</a>
					</s:if><s:else>未开始</s:else>
				</td>
				</tr>
			</s:iterator>
		</s:else>
	</tbody>
</table>
<p>
	<%@ include file="/WEB-INF/pages/common/main_orgtab_pager_train.jsp"%>
</p>
<div class="container_12 clearfix"
	style="margin-left: 0px; margin-right: 0px; width: 98%"
	id="assess_body">
</div>

<script type="text/javascript">
	$(document).ready(function(){
		$("#assess_body").attr("style","display:none");
		$("span[name='td_dutytarget']").each(function(i) {
			loadDutyTarget(this, $(this).attr("title"));
		});
	});
	
	function loadDutyTarget(obj, planId) {
		$.ajax({
			type : "get",
			url : "/ajax/query_dutytarget.xhtml?planId=" + planId,
			//data: "name=John&location=Boston",
			dataType : "html",
			success : function(data) {
				if (data != null) {
					$(obj).html(data);
				}
			}
		});
	}
	var  currentPlanId = 0;
	//显示评论列表 
	function showAssessContent(planId) {
		$("#assess_body").attr("style","display:block");
		currentPlanId = planId;
		var url = "/train/assess_outing_list_tab.xhtml";
		var data = {"planId":planId};
        //refreshListContent(url, data);
        $.ajax(url, {
            type:"POST",
            //data:{"organizationId":organizationId},
            data:data,
            dataType:"html",
            cache:false,
            success:function (a) {
                var obj = $("#assess_body");
                obj.html("");
                obj.append(a);
            },
            complete:function () {
            }
        });
	}
	
</script>